<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<!--

  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
  Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
  The contents of this file are subject to the terms of either the GNU
  General Public License Version 2 only ("GPL") or the Common Development
  and Distribution License("CDDL") (collectively, the "License").  You
  may not use this file except in compliance with the License. You can obtain
  a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
  or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
  language governing permissions and limitations under the License.
 
  When distributing the software, include this License Header Notice in each
  file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
  Sun designates this particular file as subject to the "Classpath" exception
  as provided by Sun in the GPL Version 2 section of the License file that
  accompanied this code.  If applicable, add the following below the License
  Header, with the fields enclosed by brackets [] replaced by your own
  identifying information: "Portions Copyrighted [year]
  [name of copyright owner]"
 
  Contributor(s):
 
  If you wish your version of this file to be governed by only the CDDL or
  only the GPL Version 2, indicate your decision by adding "[Contributor]
  elects to include this software in this distribution under the [CDDL or GPL
  Version 2] license."  If you don't indicate a single choice of license, a
  recipient has the option to distribute your version of this file under
  either the CDDL, the GPL Version 2 or to extend the choice of license to
  its licensees as provided above.  However, if you add GPL Version 2 code
  and therefore, elected the GPL Version 2 license, then the option applies
  only if the new code is made subject to such option by the copyright
  holder.

  @(#)package.html	1.14 07/07/02

-->

</HEAD>
<BODY BGCOLOR="white">

A POP3 protocol provider for the JavaMail API
that provides access to a POP3 message store.
Refer to <A HREF="http://www.ietf.org/rfc/rfc1939.txt" TARGET="_top">
RFC 1939</A>
for more information.
<P>
The POP3 provider provides a Store object that contains a single Folder
named "INBOX". Due to the limitations of the POP3 protocol, many of
the JavaMail API capabilities like event notification, folder management,
flag management, etc. are not allowed.  The corresponding methods throw
the MethodNotSupportedException exception; see below for details.
<P>
Note that JavaMail does <strong>not</strong> include a local store into
which messages can be downloaded and stored.  See our
<A HREF="http://java.sun.com/products/javamail/Third_Party.html" TARGET="_top">
Third Party Products</A>
web page for availability of "mbox" and "MH" local store providers.
<P>
The POP3 provider is accessed through the JavaMail APIs by using the protocol
name "pop3" or a URL of the form "pop3://user:password@host:port/INBOX".
<P>
POP3 supports only a single folder named "INBOX".
<P>
POP3 supports <strong>no</strong> permanent flags (see
{@link javax.mail.Folder#getPermanentFlags Folder.getPermanentFlags()}).
In particular, the <code>Flags.Flag.RECENT</code> flag will never be set
for POP3
messages.  It's up to the application to determine which messages in a
POP3 mailbox are "new".  There are several strategies to accomplish
this, depending on the needs of the application and the environment:
<P>
<UL>
<LI>
A simple approach would be to keep track of the newest
message seen by the application.
</LI>
<LI>
An alternative would be to keep track of the UIDs (see below)
of all messages that have been seen.
</LI>
<LI>
Another approach is to download <strong>all</strong> messages into a local
mailbox, so that all messages in the POP3 mailbox are, by
definition, new.
</LI>
</UL>
<P>
All approaches will require some permanent storage associated with the client.
<P>
POP3 does not support the <code>Folder.expunge()</code> method.  To delete and
expunge messages, set the <code>Flags.Flag.DELETED</code> flag on the messages
and close the folder using the <code>Folder.close(true)</code> method.  You
cannot expunge without closing the folder.
<P>
POP3 does not provide a "received date", so the <code>getReceivedDate</code>
method will return null.
It may be possible to examine other message headers (e.g., the
"Received" headers) to estimate the received date, but these techniques
are error-prone at best.
<P>
The POP3 provider supports the POP3 UIDL command, see
{@link com.sun.mail.pop3.POP3Folder#getUID POP3Folder.getUID()}.
You can use it as follows:
<P>
<BLOCKQUOTE><PRE>
if (folder instanceof com.sun.mail.pop3.POP3Folder) {
    com.sun.mail.pop3.POP3Folder pf =
	(com.sun.mail.pop3.POP3Folder)folder;
    String uid = pf.getUID(msg);
    if (uid != null)
	... // use it
}
</PRE></BLOCKQUOTE>
<P>
You can also pre-fetch all the UIDs for all messages like this:
<P>
<BLOCKQUOTE><PRE>
FetchProfile fp = new FetchProfile();
fp.add(UIDFolder.FetchProfileItem.UID);
folder.fetch(folder.getMessages(), fp);
</PRE></BLOCKQUOTE>
<P>
Then use the technique above to get the UID for each message.  This is
similar to the technique used with the UIDFolder interface supported by
IMAP, but note that POP3 UIDs are strings, not integers like IMAP
UIDs.  See the POP3 spec for details.
<P>
The POP3 protocol provider supports the following properties,
which may be set in the JavaMail <code>Session</code> object.
The properties are always set as strings; the Type column describes
how the string is interpreted.  For example, use
<PRE>
	props.put("mail.pop3.port", "888");
</PRE>
to set the <CODE>mail.pop3.port</CODE> property, which is of type int.
<P>
<TABLE BORDER>
<TR>
<TH>Name</TH>
<TH>Type</TH>
<TH>Description</TH>
</TR>

<TR>
<TD>mail.pop3.user</TD>
<TD>String</TD>
<TD>Default user name for POP3.</TD>
</TR>

<TR>
<TD>mail.pop3.host</TD>
<TD>String</TD>
<TD>The POP3 server to connect to.</TD>
</TR>

<TR>
<TD>mail.pop3.port</TD>
<TD>int</TD>
<TD>The POP3 server port to connect to, if the connect() method doesn't
explicitly specify one. Defaults to 110.</TD>
</TR>

<TR>
<TD>mail.pop3.connectiontimeout</TD>
<TD>int</TD>
<TD>Socket connection timeout value in milliseconds.
Default is infinite timeout.</TD>
</TR>

<TR>
<TD>mail.pop3.timeout</TD>
<TD>int</TD>
<TD>Socket I/O timeout value in milliseconds.  Default is infinite timeout.</TD>
</TR>

<TR>
<TD>mail.pop3.rsetbeforequit</TD>
<TD>boolean</TD>
<TD>
Send a POP3 RSET command when closing the folder, before sending the
QUIT command.  Useful with POP3 servers that implicitly mark all
messages that are read as "deleted"; this will prevent such messages
from being deleted and expunged unless the client requests so.  Default
is false.
</TD>
</TR>

<TR>
<TD>mail.pop3.message.class</TD>
<TD>String</TD>
<TD>
Class name of a subclass of <code>com.sun.mail.pop3.POP3Message</code>.
The subclass can be used to handle (for example) non-standard
Content-Type headers.  The subclass must have a public constructor
of the form <code>MyPOP3Message(Folder f, int msgno)
throws MessagingException</code>.
</TD>
</TR>

<TR>
<TD>mail.pop3.localaddress</TD>
<TD>String</TD>
<TD>
Local address (host name) to bind to when creating the POP3 socket.
Defaults to the address picked by the Socket class.
Should not normally need to be set, but useful with multi-homed hosts
where it's important to pick a particular local address to bind to.
</TD>
</TR>

<TR>
<TD>mail.pop3.localport</TD>
<TD>int</TD>
<TD>
Local port number to bind to when creating the POP3 socket.
Defaults to the port number picked by the Socket class.
</TD>
</TR>

<TR>
<TD>mail.pop3.apop.enable</TD>
<TD>boolean</TD>
<TD>
If set to true, use APOP instead of USER/PASS to login to the
POP3 server, if the POP3 server supports APOP.  APOP sends a
digest of the password rather than the clear text password.
Defaults to false.
</TD>
</TR>

<TR>
<TD>mail.pop3.socketFactory.class</TD>
<TD>String</TD>
<TD>
If set, specifies the name of a class that implements the
<code>javax.net.SocketFactory</code> interface.  This class
will be used to create POP3 sockets.
</TD>
</TR>

<TR>
<TD>mail.pop3.socketFactory.fallback</TD>
<TD>boolean</TD>
<TD>
If set to true, failure to create a socket using the specified
socket factory class will cause the socket to be created using
the <code>java.net.Socket</code> class.
Defaults to true.
</TD>
</TR>

<TR>
<TD>mail.pop3.socketFactory.port</TD>
<TD>int</TD>
<TD>
Specifies the port to connect to when using the specified socket
factory.
If not set, the default port will be used.
</TD>
</TR>

<TR>
<TD>mail.pop3.disabletop</TD>
<TD>boolean</TD>
<TD>
If set to true, the POP3 TOP command will not be used to fetch
message headers.  This is useful for POP3 servers that don't
properly implement the TOP command, or that provide incorrect
information in the TOP command results.
Defaults to false.
</TD>
</TR>

<TR>
<TD>mail.pop3.forgettopheaders</TD>
<TD>boolean</TD>
<TD>
If set to true, the headers that might have been retrieved using
the POP3 TOP command will be forgotten and replaced by headers
retrieved as part of the POP3 RETR command.  Some servers, such
as some versions of Microsft Exchange and IBM Lotus Notes,
will return slightly different
headers each time the TOP or RETR command is used.  To allow the
POP3 provider to properly parse the message content returned from
the RETR command, the headers also returned by the RETR command
must be used.  Setting this property to true will cause these
headers to be used, even if they differ from the headers returned
previously as a result of using the TOP command.
Defaults to false.
</TD>
</TR>

</TABLE>
<P>
In general, applications should not need to use the classes in this
package directly.  Instead, they should use the APIs defined by
<code>javax.mail</code> package (and subpackages).  Applications should
never construct instances of <code>POP3Store</code> or
<code>POP3Folder</code> directly.  Instead, they should use the
<code>Session</code> method <code>getStore</code> to acquire an
appropriate <code>Store</code> object, and from that acquire
<code>Folder</code> objects.
<P>
<strong>WARNING:</strong> The APIs unique to this package should be
considered <strong>EXPERIMENTAL</strong>.  They may be changed in the
future in ways that are incompatible with applications using the
current APIs.

</BODY>
</HTML>
